import {debounce} from './utils.js';
import BackTop from '../components/content/backTop/BackTop.vue';
//监听item中图片加载完成事件监听
export const itemListenerMixin ={
  data() {
    return {
      itemImgListenner: null
    }
  },
  mounted() {
    const refresh = debounce(this.$refs.scroll.refresh,50);
      //监听item中图片加载完成事件监听
      //保存函数
      this.itemImgListenner = ()=>{
        refresh();
      }
      this.$bus.$on('itemImageLoad', this.itemImgListenner);
  },
}
//返回顶部按钮
export const backTopMixin ={
  data() {
    return {
      isbacktop: false,
    }
  },
  components:{
    BackTop
  },
  methods: {
    showBackTop(postion){
      //判断BackTop是否显示
      this.isbacktop = (-postion.y) > 1000;
    },
    backclick(){
      /**回到顶部 */
      this.$refs.scroll.scrollTo(0, 0);
    },
  },
}